package tg.app.rj.tslx;

import java.rmi.RemoteException;
import psdi.mbo.MAXTableDomain;
import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.mbo.MboValue;
import psdi.util.MXException;

/****
 * 
 * @author pzx
 *
 */
public class FldTsdsb extends MAXTableDomain
{
  public FldTsdsb(MboValue mbv)
  {
    super(mbv);
    setRelationship("ASSET", "ASSETNUM=:"+getMboValue().getName());
    setListCriteria(" siteid=:siteid ");
    String[] strTo = { getMboValue().getName() };
    String[] strFrom = { "ASSETNUM" };
    setLookupKeyMapInOrder(strTo, strFrom);
  }

  public void action() throws MXException, RemoteException
  {
    String assetnum = getMboValue().getString();
    Mbo mbo = getMboValue().getMbo();
    if ((assetnum != null) && (!"".equalsIgnoreCase(assetnum))) {
      MboSetRemote assetset = mbo.getMboSet("$assetnum", "ASSET", "assetnum='" + assetnum + "'");
      if (!assetset.isEmpty()) {
        MboRemote assetMbo = assetset.getMbo(0);
        mbo.setValue("location", assetMbo.getString("LOCATION"), 11L);
      }
      else
      {
        mbo.setValueNull("location", 11L);
      }
    }
  }
}